package leetcode.jianzhioffer;

/**
 * @program: datastructureandalogorithm
 * @description:
 * @author: hmx
 * @create: 2021-11-01 13:38
 **/
public class JianZhiOffer52 {

    public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
        ListNode temp1 = headA;
        ListNode temp2 = headB;
        while (temp1 != temp2) {
            temp1 = temp1.next == null ? headB : temp1.next;
            temp2 = temp2.next == null ? headA : temp2.next;
        }
        return temp1;
    }

}
